package cn.pzhu.java.ch04.collectiondemo;

import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;

public class MapDemo {

	
	public static void main(String[] args) {
		Student s1=new Student(1, "zhang3");
		Student s2=new Student(2, "Li4");
		Student s3=new Student(3, "wang5");
		Map<Integer,Student> map=new HashMap<Integer,Student>();
		map.put(1, s1);
		map.put(2, s2);
		map.put(3, s3);
		
		Student s=map.get(2);
		System.out.println(s);
		Set<Integer> keys=map.keySet();
		for(Integer id:keys){
			Student stu=map.get(id);
			System.out.println("Key:"+id+" Value:"+stu.toString());
		}
		
		Collection<Student> stus=map.values();
		for(Student stu:stus){
			System.out.println(s.toString());
		}
		
		map.remove(3); //key
		
	}

}
